﻿package mortal.game.view.drugBack
{
    import Message.DB.Tables.*;
    import Message.Public.*;
    import flash.utils.*;
    import mortal.game.cache.*;
    import mortal.game.resource.info.item.*;
    import mortal.game.resource.tableConfig.*;

    public class DrugPackUtil extends Object
    {

        public function DrugPackUtil()
        {
            return;
        }// end function

        public static function getRecoverValueByType(param1:int) : int
        {
            var _loc_2:int = 0;
            var _loc_3:SFightAttribute = null;
            var _loc_5:TDrugBagRecovery = null;
            var _loc_6:Number = NaN;
            var _loc_7:int = 0;
            var _loc_4:* = DrugBackConfig.instance.getDrugRecoverDicByType(param1);
            _loc_3 = Cache.instance.role.fightAttributeExt ? (Cache.instance.role.fightAttributeExt) : (new SFightAttribute());
            switch(param1)
            {
                case EDrug._EDrugLifeBag:
                {
                    _loc_5 = _loc_4[int(Cache.instance.role.entityInfo.level / 10)] as TDrugBagRecovery;
                    _loc_6 = !isNaN(Cache.instance.vip.level) ? (1 + int(VipConfig.instance.getValueByTypeAndLv(EVipRecordType._EVipRecordTypeDrugLife, Cache.instance.vip.level)) * 0.01) : (1);
                    _loc_7 = Cache.instance.role.fightAttributeBase.maxLife + _loc_3.maxLife;
                    _loc_2 = _loc_7 * _loc_5.recoveryPercent * 0.01 * _loc_6 + _loc_5.recoveryValue + Cache.instance.buff.getBuffTypeValue(EBuffType._EBuffTypeIncOrDeCureValue);
                    break;
                }
                case EDrug._EDrugManaBag:
                {
                    _loc_5 = _loc_4[int(Cache.instance.role.entityInfo.level / 10)] as TDrugBagRecovery;
                    _loc_6 = !isNaN(Cache.instance.vip.level) ? (1 + int(VipConfig.instance.getValueByTypeAndLv(EVipRecordType._EVipRecordTypeDrugMana, Cache.instance.vip.level)) * 0.01) : (1);
                    _loc_7 = Cache.instance.role.fightAttributeBase.maxMana + _loc_3.maxMana;
                    _loc_2 = _loc_7 * _loc_5.recoveryPercent * 0.01 * _loc_6 + _loc_5.recoveryValue + Cache.instance.buff.getBuffTypeValue(EBuffType._EBuffTypeIncOrDeManaValue);
                    break;
                }
                case EDrug._EDrugPetLifeBag:
                {
                    break;
                }
                default:
                {
                    break;
                }
            }
            return _loc_2;
        }// end function

        public static function isCanUseDrugItem(param1:ItemData) : int
        {
            var _loc_2:* = param1.itemInfo.type;
            var _loc_3:* = Cache.instance.DrugPack.getMaxDrugBagAmountByType(_loc_2) - Cache.instance.DrugPack.getDataBuyType(_loc_2).leftNum;
            var _loc_4:* = int(_loc_3 / param1.itemInfo.effectEx);
            return _loc_4;
        }// end function

        public static function getCdKeyByType(param1:int)
        {
            switch(param1)
            {
                case EDrug._EDrugLifeBag:
                {
                    return new ItemData(110001000);
                }
                case EDrug._EDrugManaBag:
                {
                    return new ItemData(110010000);
                }
                case EDrug._EDrugPetLifeBag:
                {
                    return new ItemData(110120000);
                }
                case EDrug._EDrugLifeInstant:
                {
                    return new ItemData(110040000);
                }
                default:
                {
                    break;
                }
            }
            return null;
        }// end function

    }
}
